﻿<Page
    x:Class="EmprestaAE.MVVM.View.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:EmprestaAE.MVVM.View"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="using:EmprestaAE.MVVM.ViewModel"
    xmlns:view="using:EmprestaAE.MVVM.View"
    xmlns:converters="using:EmprestaAE.Common"
    mc:Ignorable="d">
    <Page.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition/>
        </TransitionCollection>
    </Page.Transitions>

    <Page.Resources>
        <viewmodel:MainVM x:Key="mainvm"/>
    </Page.Resources>

    <Grid Background="{StaticResource ApplicationBackgroundColor}"
          x:Name="layoutroot"
          DataContext="{Binding Source={StaticResource mainvm}, Path=Instance}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="6*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="20*"/>
            </Grid.ColumnDefinitions>

            <!-- title -->
            <Grid Grid.Column="1" Grid.Row="0">
                <TextBlock Style="{StaticResource S_ApplicationTitle}"                           
                           Text="{StaticResource ApplicationTitle}"/>
            </Grid>

            <!-- content -->
            <Grid Grid.Column="1" Grid.Row="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="4*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="16*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="10*"/>
                    </Grid.RowDefinitions>
                    <!--lend/borrow comands-->
                    <Grid Grid.Column="0" Grid.Row="2" Style="{StaticResource S_Grid}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Button Style="{StaticResource S_ButtonLendBorrow}"
                                Content="{StaticResource ButtonBorrowText}"
                                Grid.Row="0"
                                Command="{Binding NavigationService.NavigateCommand}">
                            <Button.CommandParameter>
                                <view:LendView/>
                            </Button.CommandParameter>
                        </Button>
                        <Button Style="{StaticResource S_ButtonLendBorrow}"
                                Content="{StaticResource ButtonLendText}"
                                Grid.Row="1"
                                Command="{Binding NavigationService.NavigateCommand}">
                            <Button.CommandParameter>
                                <view:BorrowView/>
                            </Button.CommandParameter>
                        </Button>
                    </Grid>
                    <!--borrowed items-->
                    <Grid Grid.Column="2" 
                          Grid.Row="0" 
                          Grid.RowSpan="2">
                        <Grid>                            
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="10*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="0">
                                <Button Style="{StaticResource S_ButtonHeaderCategory}"
                                        Content="{StaticResource BorrowedCategoryHeaderText}"/>
                            </Grid>
                            <Grid Grid.Column="0"
                                    Grid.Row="1"                                    
                                    Margin="0,0,20,20">
                                <GridView ItemsSource="{Binding Lends}"
                                          ItemClick="GridView_ItemClick"
                                          IsItemClickEnabled="True"                                          
                                          Style="{StaticResource S_GridViewLendsBorrows}">                                    
                                </GridView>
                            </Grid>
                            
                            
                            <Grid Grid.Column="1">
                                <Button Style="{StaticResource S_ButtonHeaderCategory}"
                                        Content="{StaticResource LentCategoryHeaderText}"/>
                            </Grid>
                            
                            <Grid Grid.Column="1"
                                    Grid.Row="1"
                                    Style="{StaticResource S_Grid}"
                                    Margin="0,0,20,20">
                                <GridView ItemsSource="{Binding Borrowings}"
                                          IsItemClickEnabled="True"
                                          ItemClick="GridView_ItemClick"
                                          Style="{StaticResource S_GridViewLendsBorrows}">
                                </GridView>
                            </Grid>
                        </Grid>
                    </Grid>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</Page>
    
    
    